<template>
  <div>
    <div class="address">
      <div>
        <p>您当前所在位置</p>
        <router-link to="/" class="link">订单详细-面料</router-link>
      </div>
    </div>
    <div class="roder-details">
      <a-tabs default-active-key="1">
        <a-tab-pane key="1" tab="订单基本信息">
          <div class="info">
            <h3 class="title">订单信息</h3>
            <div class="list">
              <div class="list-div">
                <div>
                  <p>订单编号</p>
                  <span>{{ fabricOrderDetail.orderSn }}</span>
                </div>
                <div>
                  <p>门店名称</p>
                  <span>{{ fabricOrderDetail.storeName }}</span>
                </div>
                <div>
                  <p>创建时间</p>
                  <span>{{ fabricOrderDetail.createTime }}</span>
                </div>

                <div v-if="fabricOrderDetail.payTime!='' && fabricOrderDetail.payTime!=null">
                  <p>支付时间</p>
                  <span>{{ fabricOrderDetail.payTime }}</span>
                </div>

                <!--                <div>
                                  <p>订单金额</p>
                                  <span>{{ fabricOrderDetail.orderMoney }}元</span>
                                </div>-->
                <!--<div>
                    <p>快递方式</p>
                    <span>&lt;!&ndash; {{fabricOrderDetail.courierId}} &ndash;&gt;{{courierName}}</span>
                </div>-->
                <!--<div>
                    <p>包装方式</p>
                    <span>{{fabricOrderDetail.packaging}}</span>
                </div>-->
                <!--                                <div>
                                                    <p>地址类型</p>
                                                    <span>{{fabricOrderDetail.addressType}}</span>
                                                </div>-->
                <div>
                  <p>顾客编号</p>
                  <span>{{ fabricOrderDetail.companyCode }}</span>
                </div>
                <div>
                  <p>顾客名称</p>
                  <span>{{ fabricOrderDetail.companyName }}</span>
                </div>
                <div>
                  <p>收货人</p>
                  <span>{{ fabricOrderDetail.name }}</span>
                </div>
                <div>
                  <p>收货电话</p>
                  <span>{{ fabricOrderDetail.phone }}</span>
                </div>
                <div>
                  <p>收货地址</p>
                  <span>{{ fabricOrderDetail.address }}</span>
                </div>

              </div>

            </div>
            <h3 class="title">面料信息</h3>
            <div class="list" v-for="(item,key) in cartDeatil" :key="item.id">
              <div class="list-div">
                <div>
                  <p>面料编号</p>
                  <span>{{ item.fabricInfo.fabricCode }}</span>
                </div>
                <!--                                <div>
                                                    <p style="justify-content: center;padding-left: 0px;">供应商面料编号</p>
                                                    <span>{{item.fabricInfo.sysOrgCode}}</span>
                                                </div>-->
                <div>
                  <p>面料成分</p>
                  <span>{{ item.fabricInfo.fabricContent }}</span>
                </div>

                <div>
                  <p>面料纱支</p>
                  <span>{{ item.fabricInfo.fabricShazhi }}</span>
                </div>
                <div>
                  <p>面料克重</p>
                  <span>{{ item.fabricInfo.fabricWeight }}g</span>
                </div>
                <!--<div>
                    <p>花型</p>
                    <span>人字</span>
                </div>-->
                <div>
                  <p>颜色</p>
                  <span>{{ item.fabricInfo.fabriceColor }}</span>
                </div>
                <div>
                  <p>样本</p>
                  <span>{{ item.fabricInfo.fabricSample }}</span>
                </div>
                <!--                <div>
                                  <p>幅宽</p>
                                  <span>{{ item.fabricInfo.fabricWidth }}</span>
                                </div>-->
                <div>
                  <p>门幅</p>
                  <span>{{ item.fabricInfo.menfu }}</span>
                </div>
                <div>
                  <p>季节</p>
                  <span>{{ item.fabricInfo.season }}</span>
                </div>
              </div>
              <div>
                <p></p>
                <label>
                  <p>备注信息：</p>
                  <el-input type="textarea" style="width:400px" :autosize="{ minRows: 2, maxRows: 4}" disabled
                            :value="item.remark"></el-input>
                </label>
              </div>
            </div>

            <h3 class="title">订单费用明细</h3>
            <h4 class="title2">面料费用</h4>
            <div class="table-css">

              <a-table class="table1" lign="center" :columns="cartlistcolumns" :data-source="cartDeatil"
                       :pagination="false">
                <a slot="k7" slot-scope="text" style="color:#C49D18">{{ text }}</a>
                <a slot="k6" slot-scope="text" style="color:#C49D18">{{ text }}</a>
                <a slot="k8" slot-scope="text" style="color:#C49D18">{{ text }}</a>
              </a-table>
            </div>

            <h5 class="price">合计金额：<span>{{ fabricOrderDetail.orderMoney }} 元</span></h5>
            <h5 v-if="fabricOrderDetail.priorPrice!=0" class="price">调价前金额：<span>{{
                fabricOrderDetail.priorPrice
              }}元</span></h5>
            <h5 v-if="fabricOrderDetail.priorPrice!=0" class="price">原总金额：<span>{{
                fabricOrderDetail.firstPrice
              }}元</span></h5>
            <h5 v-if="fabricOrderDetail.status!=0 && fabricOrderDetail.status!=-1 && fabricOrderDetail.deductionPay!=0"
                class="price">抵扣额度支付：<span>{{ fabricOrderDetail.deductionPay }} 元</span></h5>
            <h5 v-if="fabricOrderDetail.status!=0 && fabricOrderDetail.status!=-1 && fabricOrderDetail.monthPay!=0"
                class="price">月结剩余额度支付：<span>{{ fabricOrderDetail.monthPay }} 元</span></h5>
            <h5 v-if="fabricOrderDetail.status!=0 && fabricOrderDetail.status!=-1 && fabricOrderDetail.balancePay!=0"
                class="price">余额支付：<span>{{ fabricOrderDetail.balancePay }} 元</span></h5>

            <h3 class="title">订单备注</h3>
            <textarea @blur="updateFabricRemarkFunc()" v-model="fabricOrderRemark" class="text1"
                      style="color: rgb(153, 153, 153);"></textarea>

            <div class="btns">
              <div class="btn1" @click="payOrder" v-if="identity == 2 && fabricOrderDetail.status==0">立即支付</div>
              <!--              <div class="btn2" @click="delOrder" v-if="fabricOrderDetail.status==0">取消订单</div>-->
              <div class="btn1" @click="$router.push('/my-order')">返回</div>
            </div>
          </div>
        </a-tab-pane>

        <a-tab-pane key="2" tab="订单状态跟踪" force-render>
          <div class="info">
            <h3 class="title">订单状态跟踪</h3>
            <div v-for="(item,key) in orderTrackingList" :key="item.id">
              <h4 class="title10">{{ item.createTime }}</h4>
              <div class="text10">
                <p>订单状态:</p>
                <div>
                  <!--0未支付，1已支付，2申请售后，3已接单，4已发货，5已完成，6备库 7驳回-->
                  <span v-if="item.orderStatus==null">未支付</span>
                  <span v-if="item.orderStatus=='0'">未支付</span>
                  <span v-if="item.orderStatus=='1'">已支付</span>
                  <span v-if="item.orderStatus=='2'">申请售后</span>
                  <span v-if="item.orderStatus=='3'">已接单</span>
                  <span v-if="item.orderStatus=='4'">已发货</span>
                  <span v-if="item.orderStatus=='5'">已完成</span>
                  <span v-if="item.orderStatus=='6'">备库</span>
                  <span v-if="item.orderStatus=='7'">驳回</span>
                  <span v-if="item.orderStatus=='8'">已取消</span>
                </div>
              </div>
              <div class="text10" v-show="item.orderStatus=='4'">
                <p>运单号:</p>
                <div>
                  <span>{{ item.logisticsSn }}</span>
                </div>
              </div>

              <div class="text10">
                <p>订单事件:</p>
                <div>
                  <span>{{ item.thing }}</span>
                </div>
              </div>
              <div class="text10">
                <p>事件备注:</p>
                <div>
                  <span>{{ item.remark }}</span>
                </div>
              </div>
            </div>
          </div>
        </a-tab-pane>
        <a-tab-pane key="3" tab="售后记录跟踪">
          <div class="info">
            <h4 class="title1" style="font-weight: 700;width: auto;">售后订单列表</h4>
            <div class="table-css">
              <a-table class="table1" :row-selection="rowSelection" lign="center" :columns="afterTitle"
                       :loding="true"
                       :pagination="pagination"
                       @change="handleTableChange"
                       :data-source="afterlist">
                <router-link slot="k6" slot-scope="text,record"
                             :to="{path:'/MyAfterSales/AfterSaleFabric',query:{id:record.id}}"
                             style="color:#C49D18">查看详情
                </router-link>
                <!--<a slot="k6" slot-scope="text,record" style="color:#C49D18">查看售后状态</a>-->

              </a-table>
            </div>
          </div>
        </a-tab-pane>
      </a-tabs>
      <!--支付界面弹窗-->
      <el-drawer
          class="el-drawer__body"
          title="详细"
          size="40%"
          :with-header="false"
          :visible.sync="drawer">
        <div style="height: 30px;line-height: 30px;left: 10px;padding-left: 26px;margin-top: 16px;">
          <i class="el-icon-s-order" style="font-size: 16px;">订单结算</i>
        </div>

        <div style="margin-top: 12px;"><span
            style="color: #ADADAD;font-size: 14px;margin-left: 26px;">支付金额（元）</span></div>
        <div style="margin-top: 12px;"><span
            style="color: #333333;font-size: 18px;margin-left: 26px;">{{ fabricOrderDetail.orderMoney }}</span>
        </div>
        <div style="margin-top: 36px;"><span
            style="color: #333333;font-size: 14px;margin-left: 26px;">支付方式</span>
        </div>


        <div style="margin-top: 18px;padding-left: 26px;">
          <el-radio v-model="radio1" label="1" border @change="change_redio(radio1)">支付宝支付</el-radio>
          <el-radio v-model="radio1" label="2" border @change="change_redio(radio1)">微信支付</el-radio>
          <el-radio v-model="radio1" label="3" border @change="change_redio(radio1)">余额支付</el-radio>
        </div>

        <div style="margin-top: 10px;height: 180px;width:100%;" v-show="is_wxshow=='1'" v-loading="loading">
          <div style="margin-left: 140px">
            <p style="font-size: 14px">微信在线支付，请扫下面二维码支付</p>
          </div>
          <div style="width: 146px;height: 146px;margin-left: 160px" id="qrCode"
               ref="qrCodeDiv"></div>
        </div>

        <div style="margin-top: 36px;"><span
            style="color: #333333;font-size: 14px;margin-left: 26px;">当前余额</span>
        </div>
        <div style="margin-top: 12px;"><span
            style="color: #333333;font-size: 18px;margin-left: 26px;">月结额度剩余：{{ userDetail.remainingLimit }}元</span>
        </div>
        <div style="margin-top: 12px;"><span
            style="color: #333333;font-size: 18px;margin-left: 26px;">账户余额：{{ userDetail.accountBalance }}元</span>
        </div>
        <div style="margin-top: 12px;"><span
            style="color: #333333;font-size: 18px;margin-left: 26px;">抵扣额度：{{ userDetail.deductionLimit }}元</span>
        </div>

        <el-button type="primary" @click="paywin"
                   style="background: #303030;margin-left: 26px;margin-top: 36px;"><span
            style="font-size: 14px;color: #FFE56D">立即支付</span></el-button>
      </el-drawer>
    </div>

    <!--确认支付的弹窗-->
    <el-dialog
        title="支付提示"
        :visible.sync="dialogVisible"
        width="30%">
      <span>确定付款吗？</span>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="dialogVisible = false,buynow()">确 定</el-button>
    </span>
    </el-dialog>

    <!--支付宝支付环境-->
    <div class="pay" v-loading="loading" v-show="is_show=='1'">
    </div>

  </div>
</template>

<script>

// 售后列表表头
// @ is an alias to /src
import locale from 'ant-design-vue/es/date-picker/locale/zh_CN';
import {getAction, postAction} from "../../api/manage";
import Qs from "qs";
import QRCode from 'qrcodejs2';

const afterTitle = [
  {
    title: '序号',
    dataIndex: '',
    key: 'rowIndex',
    align: 'center',
    customRender: function (t, r, index) {
      return parseInt(index) + 1
    }
  },
  {
    title: '售后单号',
    align: "center",
    dataIndex: 'afterCode'
  },
  {
    title: '面料编号',
    align: "center",
    dataIndex: 'fabricids'
  },
  {
    title: '更新时间',
    align: "center",
    dataIndex: 'createTime'
  },
  {
    title: '售后类型',
    align: "center",
    dataIndex: "afterSalesType",
    customRender: function (text) {
      if (text == '0') {
        return '退货'
      } else if (text == '1') {
        return '换货'
      }
    },
    scopedSlots: {
      customRender: 'k4'
    },
  },
  {
    title: '状态',
    align: "center",
    dataIndex: 'afterstatus',
    customRender: function (text) {
      if (text == '0') {
        return '已提交'
      } else if (text == '1') {
        return '已驳回'
      } else if (text == '2') {
        return '售后中'
      } else if (text == '3') {
        return '已完成'
      } else if (text == '4') {
        return '已发货'
      } else if (text == '5') {
        return '平台已收货'
      }
    },
  },
  {
    title: '操作',
    align: "center",
    scopedSlots: {
      customRender: 'k6'
    }
  }
];

// 面料价格列表
const cartlistcolumns = [
  {
    title: '序号',
    dataIndex: '',
    key: 'rowIndex',
    /*width: 60,*/
    align: 'center',
    customRender: function (t, r, index) {
      return parseInt(index) + 1
    }
  },
  {
    title: '面料编号',
    align: "center",
    dataIndex: 'fabricInfo.fabricCode'
  },
  {
    title: '米数',
    align: "center",
    dataIndex: 'buyNumber'
  },
  {
    title: '阶梯价',
    align: "center",
    dataIndex: 'fabricInfo.fabricPrice'
  },
  /*{
      title: '阶梯折扣',
      align: "center",
      dataIndex: 'orderSn'
  },*/
  {
    title: '客户折扣',
    align: "center",
    dataIndex: 'fabricInfo.kehuzk',
    customRender: function (text) {
      if (text == '1') {
        return '100%'
      } else {
        if (Number(text) == 0) {
          return '100%'
        }
        return (Number(text) * 100) + "%"
      }
    }
  },
  {
    title: '折后单价',
    align: "center",
    dataIndex: 'fabricInfo.afterPrice'
  },
  {
    title: '总金额',
    align: "center",
    dataIndex: 'totalAmount'
  },
  /*{
      title: '备注',
      align: "center",
      dataIndex: 'remark'
  },*/
]
const columns1 = [{
  dataIndex: 'k1',
  key: 'k1',
  title: '序号',
},
  {
    title: '面料',
    dataIndex: 'k2',
    key: 'k2',
  },
  {
    title: '米数',
    dataIndex: 'k3',
    key: 'k3',
  },
  {
    title: '标准单价',
    key: 'k4',
    dataIndex: 'k4'
  },
  {
    title: '阶梯折扣',
    key: 'k5',
    dataIndex: 'k5'
  },
  {
    title: '客户折扣',
    key: 'k6',
    dataIndex: 'k6',
    scopedSlots: {
      customRender: 'k6'
    },
  },
  {
    title: '折后单价',
    key: 'k7',
    dataIndex: 'k7',
    scopedSlots: {
      customRender: 'k7'
    },
  },
  {
    title: '总金额',
    key: 'k8',
    dataIndex: 'k8',
    scopedSlots: {
      customRender: 'k8'
    },
  },
];
const columns7 = [{
  dataIndex: 'k1',
  key: 'k1',
  title: '序号',
},
  {
    title: '售后单号',
    dataIndex: 'k2',
    key: 'k2',
  },
  {
    title: '售后类型',
    dataIndex: 'k3',
    key: 'k3',
  },
  {
    title: '申请时间',
    key: 'k4',
    dataIndex: 'k4'
  },

  {
    title: '状态',
    key: 'k5',
    dataIndex: 'k5',
    scopedSlots: {
      customRender: 'k5'
    },
  },
  {
    title: '操作',
    key: 'k6',
    dataIndex: 'k6',
    scopedSlots: {
      customRender: 'k6'
    },
  }
];
const columns2 = [{
  dataIndex: 'k1',
  key: 'k1',
  title: '序号',
},
  {
    title: '品类',
    dataIndex: 'k2',
    key: 'k2',
  },
  {
    title: '性别',
    dataIndex: 'k3',
    key: 'k3',
  },
  {
    title: '标准单价',
    key: 'k4',
    dataIndex: 'k4'
  },
  {
    title: '阶梯折扣',
    key: 'k5',
    dataIndex: 'k5'
  },
  {
    title: '客户折扣',
    key: 'k6',
    dataIndex: 'k6',
    scopedSlots: {
      customRender: 'k6'
    },
  },
  {
    title: '折后单价',
    key: 'k7',
    dataIndex: 'k7',
    scopedSlots: {
      customRender: 'k7'
    },
  },
  {
    title: '总金额',
    key: 'k8',
    dataIndex: 'k8',
    scopedSlots: {
      customRender: 'k8'
    },
  },
];
const data1 = [{
  k1: '1',
  k2: '23341964AQ',
  k3: '2020-06-01',
  k4: '2264AA',
  k5: '40米',
  k6: '80%',
  k7: '304元/米',
  k8: '7600元'
}]
const data5 = [{
  k1: '1',
  k2: 'UOSL1334',
  k3: '返修',
  k4: '2020-06-10',
  k5: '等待审核',
  k6: '查看售后状态'
}]

export default {
  created() {
    this.getFabricDetail()
    this.Tracking()
    this.getAfterList()
    this.getuserDetail()
    this.show_userinfo()
  },
  name: 'MyAfterSales',
  data() {
    return {
      wx_order_no: '',//微信订单号
      intjishi: '',
      is_show: 0,
      is_wxshow: 0,
      is_wx: 0,
      loading: false,
      dialogVisible: false, // 确认弹窗
      userDetail: {}, // 当前账户详情
      radio1: '', // 支付方式
      drawer: false, // 支付弹窗是否显示
      courierName: '',//快递名称
      autohor_token: localStorage.getItem("token"), //token
      fabricOrderDetail: {},// 面料订单详情
      cartDeatil: [],// 面料订单中的购物车列表
      fabricOrderRemark: '', // 面料订单备注
      orderTrackingList: [], // 订单跟踪列表
      afterTitle,
      afterlist: [], // 售后订单列表
      identity: '',  // 账号身份
      url: {
        userDetail: '/fabricAndOther/getUserDetail', // 查余额
        fabricDetail: "/cart/getFabricOrderDetail", // 面料订单详情
        delOrder: "/Order/delOrder", // 取消订单接口
        buyNow: '/Order/buyNow', // 立即支付
        getFabricOrderTracking: "/Order/getFabricOrderTracking", // 面料订单状态跟踪
        listTeamAfter: '/Order/listTeamAfter',// 订单售后记录
        getcourierNamebyId: '/repair/getcourierNamebyId',//根据快递id查询快递名字
        show_data_token: '/user/interface/query_userInfoBytoken', // 查询当前账号的信息
        // 更新面料订单备注
        updateFabricRemark: '/fabric/updateFabricRemark'
      },
      // 分页
      pagination: {
        current: '',
        total: 0,
        pageSize: 10,//每页中显示10条数据
      },
      cartlistcolumns,// 面料列表的数据
      columns1,
      columns7,
      columns2,
      data1,
      data5,
      locale,
      selectedRowKeys: [],
      tab1Data: [{
        id: 1,
        name: '无需试穿'
      },
        {
          id: 2,
          name: '半成品试穿'
        },
        {
          id: 3,
          name: '毛坯半成品试穿'
        },
      ],
      tab1Idx: -1,
      tab2Data: [{
        id: 1,
        name: '常规',
        hoveName: '7个工作日'
      },
        {
          id: 2,
          name: '加急',
          hoveName: '5个工作日200元'
        },
        {
          id: 3,
          name: '特急',
          hoveName: '3个工作日400元'
        },
      ],
      tab2Idx: -1,
      tab3Data: [{
        id: 1,
        name: '来款/样式'
      },
        {
          id: 2,
          name: '改款'
        },
      ],
      tab3Idx: -1,
      tab4Data: [{
        id: 1,
        name: '派定制'
      },],
      tab4Idx: -1,
    }
  },
  computed: {
    rowSelection() {
      return {
        onChange: (selectedRowKeys, selectedRows) => {
          console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows);
        },
        getCheckboxProps: record => ({
          props: {
            disabled: record.name === 'Disabled User', // Column configuration not to be checked
            name: record.name,
          },
        }),
      };
    },
  },
  beforeDestroy() {
    //清除定时器
    clearInterval(this.intjishi);
    console.log("beforeDestroy");
  },
  destroyed() {
    //清除定时器
    clearInterval(this.intjishi);
    // alert("销毁执行=="+this.intjishi)
  },
  methods: {

    // 更新
    updateFabricRemarkFunc() {
      getAction(domain.publicUrl + this.url.updateFabricRemark, {
        'orderSn': this.fabricOrderDetail.orderSn,// 订单编号
        'remark': this.fabricOrderRemark
      }).then(res => {
        console.log('成了吗')
      })
    },
    /**
     * 生成二维码
     */
    bindQRCode(url) {
      document.getElementById("qrCode").innerHTML = "";
      new QRCode(this.$refs.qrCodeDiv, {
        text: url,
        width: 180,
        height: 180,
        colorDark: "#333333", //二维码颜色
        colorLight: "#ffffff", //二维码背景色
        correctLevel: QRCode.CorrectLevel.L//容错率，L/M/H
      })
    },
    change_redio(is_show) {
      if (is_show == '1') {
        this.is_wxshow = 0;
      } else if (is_show == '2') {
        if (this.is_wx == 0) {
          this.is_wxshow = 0;
        } else {
          this.is_wxshow = 1;
        }
      } else {
        this.is_wxshow = 0;
      }
    },
    /**
     * 获取当前登录账号的信息
     */
    show_userinfo() {
      let autohor_token = localStorage.getItem("token");
      let params = {token: autohor_token};
      postAction(domain.publicUrl + this.url.show_data_token, Qs.stringify(params)).then(res => {
        let result = res.data;
        if (result.code == 0) {
          this.identity = result.data.identity;
        }
      })
    },

    // 支付弹窗
    paywin() {
      if (this.radio1 == '3') {
        this.dialogVisible = true
        this.radio1 = '3';
        this.is_wx = 0;
        this.is_wxshow = 0;
      } else if (this.radio1 == '1') {
        this.radio1 = '1';
        this.is_wx = 0;
        this.is_wxshow = 0;
        let autohor_token = localStorage.getItem("token");
        var params = {token: autohor_token, orderType: "0", applyMethod: "1", orderSn: this.fabricOrderDetail.orderSn};
        postAction(domain.publicUrl + "/ali/pay/order/create", Qs.stringify(params)).then(res => {
          var result = res.data;
          if (result.code == "1") {
            this.drawer = false;
            this.is_show = 1;
            this.loading = false;
            document.write(result.data.body)
          } else {
            this.is_show = 0;
            this.$message.error(result.msg)
            this.loading = false;
          }
        })
      } else if (this.radio1 == '2') {
        this.loading = true;
        this.wx_order_no = '';
        let autohor_token = localStorage.getItem("token");
        var params = {token: autohor_token, orderType: "0", applyMethod: "2", orderSn: this.fabricOrderDetail.orderSn};
        postAction(domain.publicUrl + "/WxPay/wx/pay/order_create", Qs.stringify(params)).then(res => {
          var result = res.data;
          if (result.data.resultCode == "SUCCESS") {
            this.is_show = 0;
            this.is_wxshow = 1;
            this.is_wx = 1;
            this.$nextTick(function () {
              this.bindQRCode(result.data.codeURL);
            })
            this.loading = false;
            this.wx_order_no = result.msg;

            this.intjishi = setInterval(() => {
              this.wx_pay_status()
            }, 1000);
          } else {
            this.is_show = 0;
            this.is_wxshow = 0;
            this.$message.error("微信支付失败，请重新发起订单支付")
            this.loading = false;
          }
        })
      } else {
        this.radio1 = '';
        this.$notify.warning({
          title: "提示",
          message: '请选择支付方式',
          duration: 1500,
        });
      }
    },

    //微信支付状态判断
    wx_pay_status() {
      getAction(domain.publicUrl + "/logic/interface/query_wxStatusDetailBywxSn", {
        'wx_out_orderSn': this.wx_order_no
      }).then(res => {
        let result = res.data;
        if (result.code == 0) {
          if (result.data.status == 2) {//已支付
            //跳转成功界面
            clearInterval(this.intjishi);//销毁定时器
            this.$message.success("订单支付成功！已成功跳转！")
            // this.$router.push({path:'/my-order'});
            this.$router.push('/');
          } else if (result.data.status == 1) {//取消支付
            clearInterval(this.intjishi);//销毁定时器
            this.$message.error("你已取消了订单支付")
          } else {//未支付
            // window.clearInterval(this.intjishi);//销毁定时器
            // this.$message.error("请前往支付！")
          }
        } else {
          this.$message.error("请扫描微信二维码支付订单")
        }
      })
    },

    selectTab: function (dataStr, i) {
      this[dataStr] = i
    },

    // 立即支付--余额支付
    buynow() {
      getAction(domain.publicUrl + this.url.buyNow, {
        'token': this.autohor_token,
        'orderType': 3,
        'orderSn': this.fabricOrderDetail.orderSn,// 订单编号
      }).then(res => {
        this.drawer = false
        if (res.data.code == '0') {
          this.$notify.success({
            title: "提示",
            message: "支付成功",
            duration: 1500,
          });
          this.getFabricDetail()
          this.Tracking()
        } else {
          this.$notify.warning({
            title: "提示",
            message: res.data.msg,
            duration: 1500,
          });
        }
      })
    },

    // 查询用户详情
    getuserDetail() {
      getAction(domain.publicUrl + this.url.userDetail, {
        'token': this.autohor_token
      }).then(res => {
        if (res.data.code == '0') {
          this.userDetail = res.data.data
        }
      })
    },

    // 获取面料订单详情
    getFabricDetail() {
      getAction(domain.publicUrl + this.url.fabricDetail, {
        'token': this.autohor_token, // token
        'orderSn': this.$route.query.order, // 选中的订单编号
      }).then(res => {
        if (res.data.code == '0') {
          this.fabricOrderDetail = res.data.data
          this.cartDeatil = res.data.data.cartInfoList
          this.fabricOrderRemark = res.data.data.remark
          this.getcourierNamebyId(this.fabricOrderDetail.courierId);
        }
      })
    },

    //根据快递id获取快递名称
    getcourierNamebyId(id) {
      getAction(domain.publicUrl + this.url.getcourierNamebyId, {
        'id': id
      }).then(res => {
        this.courierName = res.data.data;
      })
    },
    // 取消面料订单
    delOrder() {
      getAction(domain.publicUrl + this.url.delOrder, {
        'token': this.autohor_token,
        'orderType': 3,
        'orderSn': this.$route.query.order
      }).then(res => {
        if (res.data.code == '0') {
          this.$message.success("取消订单成功！")
          this.$router.push("/my-order")
        }
      })
    },
    // 订单支付（打开支付弹窗界面）
    payOrder() {
      this.drawer = true
      /*getAction(domain.publicUrl + this.url.buyNow, {
          'token': this.autohor_token,
          'orderType': 3,
          'orderSn': this.$route.query.order,
          'remark': this.fabricOrderRemark
      }).then(res => {
          if (res.data.code == '0') {
              this.$message.success("订单支付成功！")
              this.$router.push("/my-order")
          } else {
              this.$message.error(res.data.msg)
          }
      })*/
    },

    // 订单状态跟踪
    Tracking() {
      getAction(domain.publicUrl + this.url.getFabricOrderTracking, {
        'token': this.autohor_token,
        'orderType': 3,
        'orderSn': this.$route.query.order
      }).then(res => {
        if (res.data.code == '0') {
          this.orderTrackingList = res.data.data
        }
      })
    },

    // 获取团订订单售后记录列表
    getAfterList() {
      getAction(domain.publicUrl + this.url.listTeamAfter, {
        'token': this.autohor_token,
        'orderSn': this.$route.query.order,
        'orderType': 3
      }).then(res => {
        if (res.data.code == '0') {
          this.afterlist = res.data.data.records
          this.pagination.total = res.data.data.total
          this.pagination.current = res.data.data.current
        }
      })
    },

    // 分页器方法
    handleTableChange(page, pageSize) {
      getAction(domain.publicUrl + this.url.listTeamAfter, {
        'pageNo': page.current,
        'pageSize': page.current.pageSize,
        'token': this.autohor_token,
        'orderSn': this.$route.query.order,
        'orderType': 3
      }).then(res => {
        if (res.data.code == '0') {
          this.afterlist = res.data.data.records
          this.pagination.total = res.data.data.total
          this.pagination.current = res.data.data.current
        }
      })
    },
  }
}
</script>

<style scoped lang="scss">
.roder-details {
  width: 80%;
  margin: 0 auto;
  background: #fff;
  margin-top: 20px;
  padding: 20px 35px;

  .info {
    padding-top: 30px;
    padding-left: 26px;
    position: relative;
    min-height: 800px;


    .text11 {
      display: flex;
      margin-bottom: 20px;

      & > p {
        width: 100px;
        font-weight: 100;
        font-size: 14px;
        color: #333;

      }

      div {
        h5 {
          color: #333;
          font-size: 15px;
          font-weight: 500;

          display: block;
        }

        p {
          color: #333;
          font-size: 15px;
          font-weight: 100;

          display: block;
        }
      }
    }

    .title10 {
      color: #333;
      font-weight: 700;
      font-size: 16px;
      line-height: 16px;
      margin-bottom: 20px;
    }

    .text10 {
      display: flex;
      margin-bottom: 20px;

      & > p {
        width: 100px;
        font-weight: 100;
        font-size: 14px;
        color: #333;

      }

      div {
        span {
          color: #333;
          font-size: 15px;
          font-weight: 100;

          &.b {
            font-weight: 500;
          }

          display: block;
        }
      }
    }

    .table-css {
      position: relative;

      .bz {
        width: 447px;
        height: 63px;
        background: inherit;
        background-color: rgba(255, 221, 202, 1);
        position: absolute;
        right: 0px;
        top: -63px;
        display: flex;
        align-items: center;
        justify-content: center;
        align-items: center;
        justify-content: center;
        flex-wrap: wrap;
        flex-direction: column;

        p {
          width: 100%;
          color: rgb(251, 8, 8);
          font-size: 13px;
          padding-left: 10px;
          margin-bottom: 0px;
          line-height: 16px;
        }
      }
    }

    .btns {
      margin-top: 25px;
      margin-bottom: 60px;
      display: flex;

      .btn1 {

        border-width: 0px;
        width: 105px;
        height: 42px;
        background: inherit;
        background-color: rgba(81, 81, 81, 1);
        border: none;
        border-radius: 3px;
        -moz-box-shadow: none;
        -webkit-box-shadow: none;
        box-shadow: none;
        font-family: 'PingFangSC-Medium', 'PingFang SC Medium', 'PingFang SC';
        font-weight: 500;
        font-style: normal;
        font-size: 13px;
        text-align: center;
        display: block;
        color: rgb(236, 227, 0);
        line-height: 40px;
        margin-right: 20px;
        cursor: pointer;
      }

      .btn2 {

        border-width: 0px;
        width: 105px;
        height: 42px;
        background: inherit;
        background-color: rgba(244, 244, 244, 1);
        border: none;
        border-radius: 3px;
        -moz-box-shadow: none;
        -webkit-box-shadow: none;
        box-shadow: none;
        font-family: 'PingFangSC-Medium', 'PingFang SC Medium', 'PingFang SC';
        font-weight: 500;
        font-style: normal;
        font-size: 13px;
        text-align: center;
        display: block;
        color: rgb(104, 104, 104);
        line-height: 40px;
        margin-right: 20px;
        cursor: pointer;
      }
    }


    .price {
      color: rgb(38, 38, 38);
      font-size: 16px;

      span {
        color: rgb(215, 1, 1);
      }

      margin: 35px 0px;
    }

    .text1 {
      width: 533px;
      height: 105px;
      padding: 3px 2px 3px 2px;
      font-family: 'ArialMT', 'Arial';
      font-weight: 400;
      font-style: normal;
      font-size: 13px;
      text-decoration: none;
      letter-spacing: normal;
      color: #000000;
      vertical-align: none;
      text-align: left;
      text-transform: none;
      background-color: #f9f9f9;
      border-color: transparent;
      resize: none;
      outline: none;
      padding: 10px;
    }

    .tabs {
      .tab {
        margin-bottom: 10px;
        display: flex;

        h5 {
          width: 112px;
          padding: 2px 2px 2px 24px;
          background-color: rgba(249, 249, 249, 1);
          font-size: 15px;
          color: #333;
          display: flex;
          height: 36px;
          align-items: center;
          margin: 0px !important;
          margin-right: 6px !important;
        }

        .tab-content {
          height: 36px;
          display: flex;

          p {
            border: 1px solid rgb(242, 242, 242);
            min-width: 100px;
            height: 36px;
            height: 36px;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 0 15px;
            color: #333;
            font-size: 15px;
            margin-right: 6px;

            cursor: pointer;

            b {
              display: none;
              font-weight: 700;
            }

            &.active {
              color: rgb(255, 236, 112);
              font-weight: 700;
              background-color: rgb(74, 74, 74);
            }

            &:hover {
              b {
                display: block;
              }

              span {
                display: none;
              }
            }
          }
        }
      }
    }

    h3.title {
      height: 30px;
      line-height: 30px;
      position: relative;
      font-size: 16px;
      color: #333;
      font-weight: 700;
      margin-bottom: 25px;

      &:after {
        position: absolute;
        height: 100%;
        width: 5px;
        position: absolute;
        left: -25px;
        top: 0px;
        background-color: rgba(74, 74, 74, 1);
        content: "";
      }
    }

    .title2 {
      width: 112px;
      padding: 2px 2px 2px 24px;
      font-size: 15px;
      color: #333;
      display: flex;
      height: 36px;
      align-items: center;
      margin: 0px !important;
      margin-bottom: 10px !important;
    }

    .list {
      margin-bottom: 20px;

      .list-div {
        display: flex;
        flex-wrap: wrap;

        div {
          width: 33.3%;
          display: flex;
          height: 36px;
          align-items: center;

          p {
            width: 112px;
            padding: 2px 2px 2px 24px;
            background-color: rgba(249, 249, 249, 1);
            font-size: 15px;
            color: #333;
            display: flex;
            height: 36px;
            align-items: center;
            margin: 0px !important;
          }

          span {
            width: calc(100% - 112px);
            padding: 2px 2px 2px 24px;
            font-size: 15px;
            color: #333;
            display: flex;
            height: 36px;
            align-items: center;

            &.b {
              font-weight: 700;
            }
          }
        }
      }
    }
  }
}
</style>
